<html>
<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<%@include file="/quick/include/globalScope.jsp"%>
  <head>
    <title><c:out value="${model.title}"/></title>
  </head>
<script>
Ext.onReady(function(){
	var gradeStore=new Ext.data.SimpleStore({
     'fields':['value','text'],
     data:<c:out value="${model.gradeJson}" escapeXml='false' />
	});
	var yearStore=new Ext.data.SimpleStore({
     'fields':['value','text'],
     data:<c:out value="${model.yearJson}" escapeXml='false' />
	});
	var semesterStore=new Ext.data.SimpleStore({
     'fields':['value','text'],
     data:<c:out value="${model.semesterJson}" escapeXml='false' />
	});
	var yearCollegeStore=new Ext.data.SimpleStore({
     'fields':['value','text','group'],
     data:<c:out value="${model.yearCollegeJson}" escapeXml='false' />
	});
	var gradeMajorStore=new Ext.data.SimpleStore({
     'fields':['value','text','grade','refid'],
     data:<c:out value="${model.gradeMajorJson}" escapeXml='false' />
	});

	
    
	var form = new Ext.form.FormPanel({
	      labelAlign:'right',
	      title:'专业成绩分析',
	      labelWidth:80,
	      region:'north',
	      height:g_height/3,
	      frame:true,
	      width:320,
		  url:g_rootPath+'ajax/system/parameter/save.html',	      
	      items:[{
            xtype:'combo',   
            fieldLabel:'学年度',  
            store: yearStore,   
            editable: false,   
            hiddenName:'SCHOOL_YEAR',   
            id:'_SCHOOL_YEAR',   
            displayField:'text',   
            valueField:'value',   
            typeAhead:true,   
            mode: 'local',   
            triggerAction: 'all',   
            emptyText:'请选择',   
            selectOnFocus:true,   
            resizable:true,   
            allowBlank:false,   
            anchor:'90%',
            forceSelection:true           
         },{
            xtype:'combo',   
            fieldLabel:'学期',   
            store: semesterStore,   
            editable: false,   
            hiddenName:'SCHOOL_SEMESTER',   
            id:'_SCHOOL_SEMESTER',   
            displayField:'text',   
            valueField:'value',   
            typeAhead:true,   
            mode: 'local',   
            triggerAction: 'all',   
            emptyText:'请选择',   
            selectOnFocus:true,   
            resizable:true,   
            allowBlank:false,   
            anchor:'90%',
            forceSelection:true           
         },{
            xtype:'combo',   
            fieldLabel:'年级',   
            store: gradeStore,   
            editable: false,   
            hiddenName:'GRADE',   
            id:'_GRADE',   
            displayField:'text',   
            valueField:'value',   
            typeAhead:true,   
            mode: 'local',   
            triggerAction: 'all',   
            emptyText:'请选择',   
            selectOnFocus:true,   
            resizable:true,   
            allowBlank:false,   
            anchor:'90%',
            forceSelection:true           
         },{
            xtype:'combo',   
            fieldLabel:'系',   
            store: yearCollegeStore,   
            editable: false,   
            hiddenName:'YEAR_COLLEGE',   
            id:'_YEAR_COLLEGE',   
            displayField:'text',   
            valueField:'value',   
            typeAhead:true,   
            mode: 'local',   
            triggerAction: 'all',   
            emptyText:'请选择',   
            selectOnFocus:true,   
            resizable:true,   
            allowBlank:false,   
            anchor:'90%',
            forceSelection:true           
         },{
            xtype:'combo',   
            fieldLabel:'专业',   
            store: gradeMajorStore,   
            editable: false,   
            hiddenName:'GRADE_MAJOR',   
            id:'_GRADE_MAJOR',   
            displayField:'text',   
            valueField:'value',   
            typeAhead:true,   
            mode: 'local',   
            triggerAction: 'all',   
            emptyText:'请选择',   
            selectOnFocus:true,   
            resizable:true,   
            allowBlank:false,   
            anchor:'90%',
            forceSelection:true           
         }],
         buttons:[{text:'打印',handler:function(){
           f_print(form);
         }},{text:'重置',handler:function(){
           form.getForm().reset();
         }}] 
          
	});
	
	form.render('parameter_form');   
   
    var gradeCombo=form.getForm().findField('_GRADE');
    var yearCollegeCombo=form.getForm().findField('_YEAR_COLLEGE');
    var gradeMajorCombo=form.getForm().findField('_GRADE_MAJOR');
    
	 yearCollegeCombo.lastQuery="";
	 gradeMajorCombo.lastQuery="";
	 
	 gradeCombo.on('change',function(combo){
	   yearCollegeCombo.reset();
	   gradeMajorCombo.reset();
	 });
	 yearCollegeCombo.on('change',function(combo){
	   gradeMajorCombo.reset();
	 });
	 
	 yearCollegeCombo.on('focus',function(combo){	
	    var grade=gradeCombo.getValue();
	    yearCollegeCombo.store.filterBy(function(r){
	      if(r.get('group')==grade||r.get('group')=='null') return true;
	    }); 
	 });    
	 
	 gradeMajorCombo.on('focus',function(combo){	
	    var grade=gradeCombo.getValue();
	    var refid=yearCollegeCombo.getValue();
	    gradeMajorCombo.store.filterBy(function(r){
	      if((r.get('grade')==grade&&r.get('refid')==refid)||(r.get('grade')=='null'&&r.get('refid')=='null')) return true; 
	    }); 
	 });    
    
   
});

function f_print(form){

  var year=form.getForm().findField('_SCHOOL_YEAR').getValue();
  var semester=parseInt(form.getForm().findField('_SCHOOL_SEMESTER').getValue());
  var grade=form.getForm().findField('_GRADE').getValue();
  var gradeMajor=form.getForm().findField('_GRADE_MAJOR').getValue();
  
  var yearName=form.getForm().findField('_SCHOOL_YEAR').getRawValue();
  var semesterName=form.getForm().findField('_SCHOOL_SEMESTER').getRawValue();
  var collegeName=form.getForm().findField('_YEAR_COLLEGE').getRawValue();
  var gradeMajorName=form.getForm().findField('_GRADE_MAJOR').getRawValue();
/*
  var xnd='XND[$]'+year;
  var xq='XQ[$]'+semester;
  var nj='NJ[$]'+grade;
  var zydm='ZYDM[$]'+gradeMajor;
  var xndmc='XNDMC[$]'+yearName;
  var xqmc='XQMC[$]'+semesterName;
  var yxmc='YXMC[$]'+collegeName;
  var zymc='ZYMC[$]'+gradeMajorName;
 */ 
  var xnd='SCHOOL_YEAR[$]'+year;
  var xq='SCHOOL_SEMESTER[$]'+semester;
  var nj='GRADE[$]'+grade;
  var zydm='MAJOR[$]'+gradeMajor;
  var xndmc='SCHOOL_YEAR_NAME[$]'+yearName;
  var xqmc='SCHOOL_SEMESTER_NAME[$]'+semesterName;
  var yxmc='YXMC[$]'+collegeName;
  var zymc='ZYMC[$]'+gradeMajorName;
  
//  var matrix=[['jasper','/web-inf/pages/score/print/semesterScore.jasper'],
  var matrix=[['jasper','/web-inf/pages/score/print/major_grade_statistic.jasper'],
        ['grade',grade],['gradeMajor',gradeMajor],['schoolYear',year],['schoolSemester',semester],
        ['params',xnd],['params',xq],['params',nj],
        ['params',zydm],['params',xndmc],['params',xqmc],
        ['params',yxmc],['params',zymc]
        ];
  var form=createForm(g_rootPath+'pdf/print.html',matrix);
//  var form=createForm(g_rootPath+'educational/score/semesterScorePrint.html',matrix);
  form.target="_blank";
  form.submit();
}
</script>  
    <c:if test="${not empty message}">
      <div  align="left" id="title" style="height:40px;vertical-align:bottom;bgcolor:blue;"><br><h3><STRONG><c:out value='${message}'/></STRONG></h3></div>
    </c:if>

<br>
<br>
<br>


<div id="parameter_form" align=center></div>  
  
</html>   
